package edu.towson.greenteam.order;

import edu.towson.greenteam.menu.MenuItem;
import edu.towson.greenteam.table.*;

import java.sql.Date;

public class Order {

    private int orderID;
    private MenuItem menuItem;
    private String menuItemName;
    private float price;
    private Table table;
    private boolean prepared;
    private boolean served;
    private Date startTime;
    private Date endTime;

    public Order(int id, String itemName, float currentPrice, Table tableOrderPlacedFrom) {
        this.orderID = id;
        this.menuItemName = itemName;
        this.price = currentPrice;
        this.table = tableOrderPlacedFrom;
        this.prepared = false;
        this.served = false;
    }

    public Order(int id, MenuItem menuItem, float currentPrice, Table tableOrderPlacedFrom) {
        this.orderID = id;
        this.menuItem = menuItem;
        this.menuItemName = menuItem.getName();
        this.price = currentPrice;
        this.table = tableOrderPlacedFrom;
        this.prepared = false;
        this.served = false;
    }

    public Order(MenuItem menuItem, float currentPrice, Table tableOrderPlacedFrom) {
        this.menuItem = menuItem;
        this.menuItemName = menuItem.getName();
        this.price = currentPrice;
        this.table = tableOrderPlacedFrom;
        this.prepared = false;
        this.served = false;
    }

    public Order getOrder() {
        return this;
    }

    public int getId() {
        return this.orderID;
    }
    
    public void setId(int orderID) {
        this.orderID = orderID;
    }

    public long getTotalTime() {
        if (endTime != null) {
            return startTime.getTime() - endTime.getTime();
        } else {
            return startTime.getTime() - System.currentTimeMillis();
        }
    }

    

    public String getMenuItemName() {
        return menuItemName;
    }

    public MenuItem getMenuItem() {
        return menuItem;
    }

    public float getPrice() {
        return price;
    }

    public Table getTable() {
        return table;
    }

    public boolean isServed() {
        return served;
    }

    public void setServed(boolean served) {
        this.served = served;
    }

    public boolean isPrepared() {
        return prepared;
    }

    public void setPrepared(boolean prepared) {
        this.prepared = prepared;
    }

    public Date getStartTime() {
        return startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
}
